# coding=utf-8
# Chern-C
# Copyright (C) 2024 NJU-SAML
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from typing import Dict, List, Literal, Optional, Union
from pydantic import BaseModel


class Endpoint(BaseModel):
    apikeys: List[str]
    proxy: Optional[str] = None
    baseurl: str
    model: str
    provider: Literal["openai"] = "openai"
    api_type: Literal["chat", "embedding"] = "chat"
    features: Dict[str, Union[str, int, float, List[str], List[int], List[float]]]
    rate_limit: int = 1024


class CherncConfig(BaseModel):
    endpoints: List[Endpoint] = []
    max_token_num: int = 4096
    token_num_method: str = "deepseek-chat"
    mark_translation_position: bool = True
    mark_translation_source: bool = False
    source_path: str = "src"
    max_project_repair: int = 16
